<?php

namespace app\api\model;

use think\Model;


class UserCoupon extends Model
{


    // 表名
    protected $name = 'user_coupon';

    protected $append = [
        'validity_time'
    ];

    public function getValidityTimeAttr($value,$data){
        $startYear=date('Y',$data['start_time']);
        $startTime=date('Y年m月d日',$data['start_time']);
        $endYear=date('Y',$data['end_time']);
        if($startYear===$endYear){
            $endTime=date('m月d日',$data['end_time']);
        }else{
            $endTime=date('Y年m月d日',$data['end_time']);
        }
        return $startTime.'—'.$endTime;
    }

}
